/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

// 数组转化为树形数据
export function dataToTree(list, val) {
  const arr = []
  list.forEach((item) => {
    if (item.pid === val) {
      const children = dataToTree(list, item.id)
      if (children.length) {
        item.children = children
      }
      arr.push(item)
    }
  })
  return arr
}
